package com.lwz.common.utils

import android.app.Activity

/**
 * @Description: 类作用描述
 * @Author: chad
 * @CreateDate: 2025/5/8 12:32
 * @Version: 1.0
 */
object ActivityCollector {
    private val activities = ArrayList<Activity>()
    fun addActivity(activity: Activity) {
        activities.add(activity)
    }
    fun removeActivity(activity: Activity) {
        activities.remove(activity)
    }
    private fun finishAll() {
        for (activity in activities) {
            if (!activity.isFinishing) {
                activity.finish()
            }
        }
        activities.clear()
    }
    fun exitApp() {
        finishAll()
        android.os.Process.killProcess(android.os.Process.myPid())
    }
}